package io;

import java.io.FileOutputStream;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * 像文件中写入字符数据，并且读取数据
 */
public class Test1 {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("fos.txt", true);
        for (char c = 'a'; c <= 'z'; ++c) {
            fos.write(c);
        }
        for (char c = 'a'; c <= 'z'; ++c) {
            fos.write(c);
        }
        System.out.println("数据写出完毕");
        fos.close();
        FileInputStream fis = new FileInputStream("fos.txt");
        int d;
        while (( d = fis.read()) != -1){//-1表示文件结束
            System.out.println((char)d);
        }
        fis.close();
    }
}